# Contributor: Mark Riedesel <mark@klowner.com>
# Maintainer: Mark Riedesel <mark@klowner.com>
pkgname=openimageio
pkgver=1.8.15
pkgrel=10
pkgdesc="Image I/O library supporting a multitude of image formats"
options="!check" # 100 out of 120 tests fail
url="https://sites.google.com/site/openimageio/"
arch="all !armv7 !aarch64 !armhf !mips !mips64"  # build errors openexr>=2.5.1
license="BSD-3-Clause"
# NOTE: OpenColorIO and OpenImageIO are cross dependent. If an ABI incompatible
# update is done in one, the other also needs to be rebuilt.
makedepends="cmake giflib-dev zlib-dev boost-dev libjpeg-turbo-dev libpng-dev tiff-dev
	glew-dev python3-dev openexr-dev ffmpeg-dev
	libraw-dev libwebp-dev freetype-dev qt5-qtbase-dev mesa-dev openssl-dev
	openjpeg-dev opencolorio-dev"
subpackages="py3-$pkgname:_python $pkgname-dev $pkgname-doc $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/OpenImageIO/oiio/archive/Release-$pkgver.tar.gz
	boost-python.patch
	"
builddir="$srcdir/oiio-Release-$pkgver"

build() {
	mkdir build && cd build
	cmake .. \
		-DUSE_OPENSSL=ON \
		-DUSE_PYTHON=ON \
		-DPYTHON_VERSION=3.7 \
		-DUSE_NUKE=OFF \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_RPATH=ON \
		-DSTOP_ON_WARNING=OFF \
		-DOIIO_BUILD_TESTS=OFF \
		-DOIIO_BUILD_TOOLS=ON \
		-DINSTALL_FONTS=OFF
	make
}

package() {
	cd build
	make DESTDIR="$pkgdir" install
}

tools() {
	pkgdesc="Tools for manipulating a multitude of image formats"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

_python() {
	local pyver="${subpkgname:2:1}"
	pkgdesc="Python $pyver bindings for OpenImageIO image I/O library"
	depends="python$pyver"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python$pyver* "$subpkgdir"/usr/lib/
}

sha512sums="e022e5c7e300d3dd952bcf3476e1b676a8931f67ba6b3959b26c75b9709907ac1c1b99de651f5876045f9a333e325a161b0d5159cb5bf385eb4f9f90a04707c7  openimageio-1.8.15.tar.gz
6f2fa329a1854be4e0dd358a1d2e0134a53422b63b5bef161a4dddfb4416a66e614afd063b15d2af56ac131c511c28b1b8f50ca6d10f00342ac2f111a23a7f0e  boost-python.patch"
